package br.com.caelum.vraptor.dao;

import javax.persistence.NoResultException;
import br.com.caelum.vraptor.entidades.Administrador;

public class AdministradorDAO extends GenericJPADAO<Administrador>{
	
	
	public AdministradorDAO() {
		this.persistentClass=Administrador.class;
	}
	
	public Administrador find(String matricula, String senha){
        try{
                Administrador adm = getEm().createQuery("select a from Administrador a where a.matricula = :matricula and a.senha = :senha", Administrador.class)
                                .setParameter("matricula", matricula)
                                .setParameter("senha", senha)
                                .getSingleResult();
                return adm;
        }
        catch(NoResultException e){
                return null;
        }
	}

}
